import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { QuestionsVO, QuestionsForm, QuestionsQuery } from '@/api/answer/questions/types';

/**
 * 查询题目列表
 * @param query
 * @returns {*}
 */

export const listQuestions = (query?: QuestionsQuery): AxiosPromise<QuestionsVO[]> => {
  return request({
    url: '/answer/questions/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询题目详细
 * @param questionId
 */
export const getQuestions = (questionId: string | number): AxiosPromise<QuestionsVO> => {
  return request({
    url: '/answer/questions/' + questionId,
    method: 'get'
  });
};

/**
 * 新增题目
 * @param data
 */
export const addQuestions = (data: QuestionsForm) => {
  return request({
    url: '/answer/questions',
    method: 'post',
    data: data
  });
};

/**
 * 修改题目
 * @param data
 */
export const updateQuestions = (data: QuestionsForm) => {
  return request({
    url: '/answer/questions',
    method: 'put',
    data: data
  });
};

/**
 * 删除题目
 * @param questionId
 */
export const delQuestions = (questionId: string | number | Array<string | number>) => {
  return request({
    url: '/answer/questions/' + questionId,
    method: 'delete'
  });
};
